package com.example.live.controller;

/**
 * @author:zhuzewen
 * @data:2024/12/16 0016 11:33
 */
import com.example.live.dto.RoomInfo;
import com.example.live.service.RoomInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/live/roomInfos")
public class RoomInfoController {

    @Autowired
    private RoomInfoService roomInfoService;

    @PostMapping
    public void addRoomInfo(@RequestBody RoomInfo roomInfo) {
        roomInfoService.addRoomInfo(roomInfo);
    }

    @DeleteMapping("/{id}")
    public void deleteRoomInfo(@PathVariable String id) {
        roomInfoService.deleteRoomInfoById(id);
    }

    @PutMapping
    public void updateRoomInfo(@RequestBody RoomInfo roomInfo) {
        roomInfoService.updateRoomInfo(roomInfo);
    }

    @GetMapping("/{id}")
    public RoomInfo getRoomInfo(@PathVariable String id) {
        return roomInfoService.getRoomInfoById(id);
    }

    @GetMapping
    public List<RoomInfo> getAllRoomInfos() {

        return roomInfoService.getAllRoomInfos();
    }
}

